package main

import (
	"encoding/hex"
	"fmt"
	"unionPay/iso8583"
)

func main() {
	var h string = "2e02303433353439313031303030202020303030313030303020202041410000303030303030303000303030303030313030e23a448188e18018000000001000008131393238393230303030313530303030303235383033333030303031313330313831363035303030303831313831363035313133303131333035343131303132303030383932303130303030303830303034383838383030303030303030303030363132333435363738313233343536373839303132333435d6d0b9fad2f8c1aa4348494e4120554e494f4e5041592053494d554c41544f5220202020202020203030394153414f30303231333135363032373030303030303030303730303030303030303030303032373030303039362020202020202020202020202020202020202020202020202020202020202020435550414d303030303030303030313030303030303034303230323031313330313831363035303030303831202020202020202020202020202020202020202030383439313031303030303433353143533232303030303034353033313030303030202020303030303030303030303030303030303030303541454336454130"
	data, _ := hex.DecodeString(h)
	fmt.Println(len(data))
	msg := iso8583.NewMessage()
	msg.Do(data)
	fmt.Printf("%+v\n\t", msg)

	fer := msg.Fields[61]
	fmt.Printf("%+v\n\t", fer)
	f61 := fer.(*iso8583.Field61)
	fmt.Printf("%+v\n\t", f61)
	//f61 := iso8583.NewKidField61(&f.Field)
	fmt.Printf("%+v\n\t", f61.Kid.KidID)
	fmt.Printf("%+v\n\t", f61.Kid.KidCVV)
	fmt.Printf("%+v\n\t", f61.Kid.KidPVV)
	fmt.Printf("%+v\n\t", f61.Kid.KidNoCardChValue)
	fmt.Printf("%+v\n\t", f61.Kid.KidARQCValue)
	fmt.Printf("%+v\n\t", f61.Kid.KidSafeValue)
	for _, v := range msg.Head.Heads {
		fmt.Printf("%+v\n\t", v)
	}
	fmt.Printf("%+v\n\t", msg.MessageTypeCode)
	for _, i := range msg.Bit.Bits {
		if i == 1 {
			continue
		}
		fmt.Printf("name:%d->vaue:%s \n\t", msg.Fields[i].Name(), msg.Fields[i].ValueString())
	}

	//server.WiteString("hello")
	//select {}
}
func init() {
	//go server.NewClient("10008", "localhost").Connet()
	//定义服务端口
	//go server.New("30008").Serv()
}
